<template>
	<view>
		<view class="main">
			<text class="title">您的反馈是我们进步的最大源泉</text>
			<view class="txt-area">
				<u--textarea  v-model="content" height="150" :maxlength="200" border="none" placeholder="请输入"></u--textarea>
			</view>
			<u-button type="primary" text="发送" @click="sendFeedback"></u-button>
		</view>

	</view>
</template>

<script>
	import {
		sendfeedback
	} from "@/common/http.api.js"
	import {
		formatBr
	} from "@/utils/formatBr.js"
	export default {
		data() {
			return {
				content: '',
				timer:null
			}
		},
		methods: {
			 sendFeedback() {
				if(!this.content) return uni.$showMsg('不能发送空内容哦~','error')
				if(this.timer) clearTimeout(this.timer)
				this.timer = setTimeout(async()=>{
					let userId = this.$store.state.userId
					this.content = formatBr(this.content)
					const res = await sendfeedback({
						userId,
						info: this.content
					})
					if (res.code === 0) uni.$showMsg('您的反馈我们已查收', 'none')
					this.content = ''
				},800)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 20rpx;
		.title{
			font-size: 14px;
			font-weight: bold;
			margin-bottom: 20rpx;
		}
		.txt-area{
			width: 90%;
			margin-bottom: 200rpx;
		}
	}
</style>
